﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Threading;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Telerik.Examples.WP;
using Telerik.Windows.Controls;

namespace TestMatrix.Phone
{
    public partial class Page1 : PhoneApplicationPage
    {
        private List<MovieViewModel> items;
        private int lastLoadedIndex = 0;
        private ObservableCollection<MovieViewModel> source = new ObservableCollection<MovieViewModel>();
        public Page1()
        {
            InitializeComponent();

            this.jumpList.ItemsSource = this.GetItems();

            //RadScaleMoveAndRotateAnimation scaleMoveRotateAnimation = this.Resources["scaleMoveRotateAnimation"] as RadScaleMoveAndRotateAnimation;
            //scaleMoveRotateAnimation.RotateAnimation.Axes = PerspectiveAnimationAxis.X;
            //scaleMoveRotateAnimation.RotateAnimation.StartAngleX = 360;
            //scaleMoveRotateAnimation.RotateAnimation.EndAngleX = 0;
            //scaleMoveRotateAnimation.RotateAnimation.Direction = PerspectiveAnimationDirection.CounterClockwise;

            //scaleMoveRotateAnimation.RotateAnimation.SpeedRatio = 0.05;

            //scaleMoveRotateAnimation.RotateAnimation.RepeatBehavior = System.Windows.Media.Animation.RepeatBehavior.Forever;
            //if (scaleMoveRotateAnimation != null)
            //{
            //    RadAnimationManager.Play(this.jumpList, scaleMoveRotateAnimation);
            //}
           
        }

      
        private List<MovieViewModel> GetItems()
        {
            using (XmlReader xmlReader = XmlReader.Create("JumpList/NetFlixTop50.xml"))
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(List<MovieViewModel>));
                List<MovieViewModel> movies = deserializer.Deserialize(xmlReader) as List<MovieViewModel>;

                return movies;
            }
        }
        private void jumplist_btnDown(object sender, System.Windows.Input.MouseEventArgs e)
        {
            //string text = ((TextBlock)e.OriginalSource).Text;

            // RadJumpList rjl = (RadJumpList)sender;
            // ((TextBlock)e.OriginalSource).Text;

            // TextBlock txb =
            //     rjl.FindName("txb_Type") as TextBlock;
            //// txb.Text=
            //text = ((TextBlock)this.jumpList.GroupDescriptors[1]).Text;
            //TextBlock texttest = (TextBlock)this.jumpList.FindName("txb_Type");

        }

        private void jumpList_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            //(TextBlock)this.jumpList.SelectedItem
        }
    }
}